import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Administrator
 * Date: 2022-9-02
 * Time: 上午 0:37
 */
public class Demo {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        String str1 = scan.nextLine();
        int count = 0;

        for(int i = 0; i < str.length(); i++) {
            if(str1.equalsIgnoreCase(str.charAt(i)+"")) {
                count++;
            }
        }

        System.out.println(count);
    }
}
